
// 计算欧几里得距离


function colorDistance(color1, color2) {


  const [r1, g1, b1] = color1;


  const [r2, g2, b2] = color2;


  return Math.sqrt(


      Math.pow(r1 - r2, 2) +


      Math.pow(g1 - g2, 2) +


      Math.pow(b1 - b2, 2)


  );


}

// 判断两种颜色是否接近

function areColorsClose(threshold = 50) {


    const rgb1 = [204,197, 187];     // 地砖


    const rgb2 = [205, 210, 204];    // 云雾


    const result = colorDistance(rgb1, rgb2) < threshold;

    console.log('result', result);
    
    return result;

}

areColorsClose();